package com.gbq.qimo.servlet;

import com.gbq.qimo.pojo.Student;
import com.gbq.qimo.service.StudentService;
import com.gbq.qimo.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName StudentMainServlet
 * @Description TODO
 * @Author guobenqi
 * @Date 2021/6/6 10:02
 */
@WebServlet("/studentMain")
public class StudentMainServlet extends HttpServlet {
    private StudentService studentService = new StudentServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Student student = (Student) request.getSession().getAttribute("user");
        int id = student.getId();

        student = studentService.findStudentById(id);
        request.setAttribute("student",student);
        request.getRequestDispatcher("/student.jsp").forward(request,response);
    }
}
